package com.mystaggeredview;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.mystaggeredview.adapter.RecyclerAdapter;
import com.mystaggeredview.base.BaseActivity;
import com.mystaggeredview.utils.showImages;

import butterknife.BindView;

public class MainActivity extends BaseActivity {

    @BindView(R.id.rccyclerView)
    RecyclerView rccyclerView;

    RecyclerAdapter adapter;
    @Override
    protected int getResourcesId() {
        return R.layout.activity_main;
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        Log.e(TAG,"这是一个");

        final StaggeredGridLayoutManager staggeredGridLayoutManager=new StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.VERTICAL);
        staggeredGridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
        staggeredGridLayoutManager.invalidateSpanAssignments();
        rccyclerView.setLayoutManager(staggeredGridLayoutManager);
        adapter=new RecyclerAdapter(mContext,showImages.imageUrls);
        rccyclerView.setAdapter(adapter);
        adapter.setOnItemClick(new RecyclerAdapter.OnItemClick() {
            @Override
            public void OnClick(View view, int position) {
                Toast.makeText(mContext,position+"",Toast.LENGTH_SHORT).show();
            }
        });

    }

}
